import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDShopGood {
	/**货品编号*/
	id,
	/**商店类型--1集市2流浪商人3积分商店4限购商店5神秘商人6观影礼包*/
	shopId,
	/**分组*/
	group,
	/**描述//配置语言表key*/
	desc,
	/**开启等级*/
	unlockLevel,
	/**随机值下限--大于等级*/
	rateLow,
	/**随机值上限--小于*/
	rateUp,
	/**活动id--配置时间*/
	activityID,
	/**奖励id--配掉落id则不掉落购买物品。--不配置不读取，>0读取*/
	drop,
	/**物品类型--1-5道具表id(1.资源点2.道具3.装备4.符文5.魔纹)6.宠物99.dropSet*/
	itemType,
	/**购买道具物品ID*/
	itemId,
	/**购买道具数量*/
	itemNum,
	/**消耗道具ID--item.id*/
	costItemId,
	/**消耗道具数量*/
	costItemNum,
	/**消耗道具ID_2--一般只需要配置一个，特殊的才需要两个小号*/
	costItemId_2,
	/**消耗道具数量_2--一般只需要配置一个，特殊的才需要两个小号*/
	costItemNum_2,
	/**推荐角标*/
	showCorner,
	/**显示原价*/
	showNum,
	/**添加特效id如果=0则没有特效*/
	effect,
	/**限购id--BuyTimeLimit表--刷新类型的商品不能配置限购id*/
	limitId,
	/**购买判断条件--任务id*/
	missonID,
	/**显示优惠角标*/
	discountsCorner,
	/**优惠数值*/
	discountsNum,
	/**是否支持批量购买。是点击弹出购买弹窗*/
	bulkBuy,
	/**商品名称*/
	name,
	/**开启VIP等级*/
	reqVip,

	/**枚举数量*/
	EnumCount
}



export class CDShopGood{
	/**货品编号*/
	public id: number;
	/**商店类型--1集市2流浪商人3积分商店4限购商店5神秘商人6观影礼包*/
	public shopId: number;
	/**分组*/
	public group: number;
	/**描述//配置语言表key*/
	public desc: number;
	/**开启等级*/
	public unlockLevel: number;
	/**随机值下限--大于等级*/
	public rateLow: number;
	/**随机值上限--小于*/
	public rateUp: number;
	/**活动id--配置时间*/
	public activityID: number;
	/**奖励id--配掉落id则不掉落购买物品。--不配置不读取，>0读取*/
	public drop: number;
	/**物品类型--1-5道具表id(1.资源点2.道具3.装备4.符文5.魔纹)6.宠物99.dropSet*/
	public itemType: number;
	/**购买道具物品ID*/
	public itemId: number;
	/**购买道具数量*/
	public itemNum: number;
	/**消耗道具ID--item.id*/
	public costItemId: number;
	/**消耗道具数量*/
	public costItemNum: number;
	/**消耗道具ID_2--一般只需要配置一个，特殊的才需要两个小号*/
	public costItemId_2: number;
	/**消耗道具数量_2--一般只需要配置一个，特殊的才需要两个小号*/
	public costItemNum_2: number;
	/**推荐角标*/
	public showCorner: number;
	/**显示原价*/
	public showNum: number;
	/**添加特效id如果=0则没有特效*/
	public effect: string;
	/**限购id--BuyTimeLimit表--刷新类型的商品不能配置限购id*/
	public limitId: number;
	/**购买判断条件--任务id*/
	public missonID: number;
	/**显示优惠角标*/
	public discountsCorner: number;
	/**优惠数值*/
	public discountsNum: number;
	/**是否支持批量购买。是点击弹出购买弹窗*/
	public bulkBuy: number;
	/**商品名称*/
	public name: number;
	/**开启VIP等级*/
	public reqVip: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDShopGood.id: return this.id;
			case E_CDShopGood.shopId: return this.shopId;
			case E_CDShopGood.group: return this.group;
			case E_CDShopGood.desc: return this.desc;
			case E_CDShopGood.unlockLevel: return this.unlockLevel;
			case E_CDShopGood.rateLow: return this.rateLow;
			case E_CDShopGood.rateUp: return this.rateUp;
			case E_CDShopGood.activityID: return this.activityID;
			case E_CDShopGood.drop: return this.drop;
			case E_CDShopGood.itemType: return this.itemType;
			case E_CDShopGood.itemId: return this.itemId;
			case E_CDShopGood.itemNum: return this.itemNum;
			case E_CDShopGood.costItemId: return this.costItemId;
			case E_CDShopGood.costItemNum: return this.costItemNum;
			case E_CDShopGood.costItemId_2: return this.costItemId_2;
			case E_CDShopGood.costItemNum_2: return this.costItemNum_2;
			case E_CDShopGood.showCorner: return this.showCorner;
			case E_CDShopGood.showNum: return this.showNum;
			case E_CDShopGood.effect: return this.effect;
			case E_CDShopGood.limitId: return this.limitId;
			case E_CDShopGood.missonID: return this.missonID;
			case E_CDShopGood.discountsCorner: return this.discountsCorner;
			case E_CDShopGood.discountsNum: return this.discountsNum;
			case E_CDShopGood.bulkBuy: return this.bulkBuy;
			case E_CDShopGood.name: return this.name;
			case E_CDShopGood.reqVip: return this.reqVip;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDShopGood.id: this.id = v; break;
			case E_CDShopGood.shopId: this.shopId = v; break;
			case E_CDShopGood.group: this.group = v; break;
			case E_CDShopGood.desc: this.desc = v; break;
			case E_CDShopGood.unlockLevel: this.unlockLevel = v; break;
			case E_CDShopGood.rateLow: this.rateLow = v; break;
			case E_CDShopGood.rateUp: this.rateUp = v; break;
			case E_CDShopGood.activityID: this.activityID = v; break;
			case E_CDShopGood.drop: this.drop = v; break;
			case E_CDShopGood.itemType: this.itemType = v; break;
			case E_CDShopGood.itemId: this.itemId = v; break;
			case E_CDShopGood.itemNum: this.itemNum = v; break;
			case E_CDShopGood.costItemId: this.costItemId = v; break;
			case E_CDShopGood.costItemNum: this.costItemNum = v; break;
			case E_CDShopGood.costItemId_2: this.costItemId_2 = v; break;
			case E_CDShopGood.costItemNum_2: this.costItemNum_2 = v; break;
			case E_CDShopGood.showCorner: this.showCorner = v; break;
			case E_CDShopGood.showNum: this.showNum = v; break;
			case E_CDShopGood.effect: this.effect = v; break;
			case E_CDShopGood.limitId: this.limitId = v; break;
			case E_CDShopGood.missonID: this.missonID = v; break;
			case E_CDShopGood.discountsCorner: this.discountsCorner = v; break;
			case E_CDShopGood.discountsNum: this.discountsNum = v; break;
			case E_CDShopGood.bulkBuy: this.bulkBuy = v; break;
			case E_CDShopGood.name: this.name = v; break;
			case E_CDShopGood.reqVip: this.reqVip = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDShopGood> = new HashMap<number, CDShopGood>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDShopGood[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDShopGood();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].shopId = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].group = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].unlockLevel = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rateLow = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rateUp = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].activityID = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].drop = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].itemType = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].itemId = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].itemNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costItemId = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costItemNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costItemId_2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costItemNum_2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].showCorner = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].showNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].effect = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].limitId = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].missonID = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].discountsCorner = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].discountsNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].bulkBuy = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].reqVip = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDShopGood{
		return this.datas ? this.datas.get(id) : null;
	}
}
